<?php
//虚拟数据
// $arr = array("base_resp"=>array("ret"=>"0"));
// print_r(json_encode($arr));
// exit;
//微信账号验证
$arr = array(
    'username'=>$_POST['user'], //wx公众帐号
    'pwd'=>md5($_POST['pass']), //wx公众帐号密码
    'f'=>'json'
 //'imagecode' => $_POST['code'];
);

if (isset($_POST['code'])) {
    $arr['imgcode'] = $_POST['code'];
}

$file = dirname(__FILE__).'/cookie/cookie_'.$arr['username'].'.txt';

// ../cookie/cookie_jcs3800.txt

$headers = array(
    'User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36',
    'Referer:https://mp.weixin.qq.com/',
);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://mp.weixin.qq.com/cgi-bin/login');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2 );
curl_setopt($curl, CURLOPT_TIMEOUT, 10 );   
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($arr));
curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);

if (!empty($arr['imgcode'])) {
    curl_setopt($curl, CURLOPT_COOKIEFILE, $file);
}

$result = curl_exec ($curl);
curl_close ( $curl );
echo $result;